package com.scs.application.utils;

import com.scs.application.core.exception.BusinessException;

import javax.validation.ValidationException;

public interface BatchSaveHandler<E> {
    /**
     * @param currentIndex 在总的list中的索引，从1开始
     * @param entity
     * @throws ValidationException
     */
    default void doValidate(int currentIndex, E entity) throws ValidationException {

    }

    default void onValidateError(int currentIndex, E entity, ValidationException e) {

    }

    default void doSave(int currentIndex, E entity) throws BusinessException {

    }


    default void onSaveError(int currentIndex, E entity, BusinessException e) {

    }

    default void onSaveSuccess(int currentIndex, E entity) {

    }
}
